﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace ST.Buz.Base.Entity
{
	/// <summary>
	/// 用户表
	/// </summary>
	[Serializable]
	[Table("Sys_User")]
	public partial class Sys_User
	{
		[Key]
		[Column("ID")]
		public int ID { get; set; }

		/// <summary>
		/// 角色类型
		/// <see cref="ST.Buz.Base.Enums.UserRoleType"/>
		/// </summary>
		[Display(Name = "角色类型")]
		[Column("RoleType")]
		public int RoleType { get; set; }

		/// <summary>
		/// 用户类型
		/// 小程序根据该字段动态设置tabbar
		/// <see cref="ST.Buz.Base.Enums.UserType"/>
		/// </summary>
		[Display(Name = "用户类型")]
		[Column("UserType")]
		public int UserType { get; set; }

		/// <summary>
		/// 部门ID
		/// </summary>
		[Display(Name = "部门")]
		[Column("DeptID")]
		public int DeptID { get; set; }

		/// <summary>
		/// 登录帐号
		/// </summary>
		[Column("Code")]
		[Display(Name = "登录帐号")]
		[StringLength(100, ErrorMessage = "{0}长度不能超过{1}")]//{1}最大，{2}最小
		public string Code { get; set; }

		/// <summary>
		/// 登录密码
		/// </summary>
		[Column("Passwd")]
		[Display(Name = "登录密码")]
		[StringLength(64, ErrorMessage = "{0}长度不能超过{1}")]
		[JsonIgnore]
		public string Passwd { get; set; }

		/// <summary>
		/// 密码加盐
		/// </summary>
		[Column("PasswdSalt")]
		[StringLength(32, ErrorMessage = "{0}长度不能超过{1}")]
		[JsonIgnore]
		public string PasswdSalt { get; set; }

		/// <summary>
		/// 姓名
		/// </summary>
		[Column("Name")]
		[Display(Name = "姓名")]
		[StringLength(20, ErrorMessage = "{0}长度不能超过{1}")]
		public string Name { get; set; }

		/// <summary>
		/// 拼音助记码
		/// </summary>
		[Column("PYCode")]
		[Display(Name = "拼音助记码")]
		[StringLength(20, ErrorMessage = "{0}长度不能超过{1}")]
		public string PYCode { get; set; }

		/// <summary>
		/// 身份证号
		/// </summary>
		[Column("IDCardNo")]
		[Display(Name = "身份证号")]
		[StringLength(20, ErrorMessage = "{0}长度不能超过{1}")]
		[RegularExpression(@"^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$", ErrorMessage = "身份证号格式不正确")]
		public string IDCardNo { get; set; }

		/// <summary>
		/// 昵称
		/// </summary>
		[Column("NickName")]
		[StringLength(50, ErrorMessage = "{0}长度不能超过{1}")]
		public string NickName { get; set; }

		/// <summary>
		/// 性别（0：未知，1：男：2：女）
		/// </summary>
		[Column("Gender")]
		public int Gender { get; set; }

		/// <summary>
		/// 联系电话
		/// </summary>
		[Column("Phone")]
		[StringLength(20, ErrorMessage = "{0}长度不能超过{1}")]
		public string Phone { get; set; }

		/// <summary>
		/// 手机号
		/// </summary>
		[Column("Mobile")]
		[StringLength(15, ErrorMessage = "{0}长度不能超过{1}")]
		public string Mobile { get; set; }

		/// <summary>
		/// Email
		/// </summary>
		[Column("Email")]
		[StringLength(50, ErrorMessage = "{0}长度不能超过{1}")]
		public string Email { get; set; }

		/// <summary>
		/// 民族
		/// </summary>
		[Display(Name = "民族")]
		[StringLength(10, ErrorMessage = "{0}长度不能超过{1}")]
		public string Nation { get; set; }

		/// <summary>
		/// 国家
		/// </summary>
		[Column("Country")]
		[StringLength(50, ErrorMessage = "{0}长度不能超过{1}")]
		public string Country { get; set; }

		/// <summary>
		/// 省
		/// </summary>
		[Column("Province")]
		[StringLength(50, ErrorMessage = "{0}长度不能超过{1}")]
		public string Province { get; set; }

		/// <summary>
		/// 市
		/// </summary>
		[Column("City")]
		[StringLength(50, ErrorMessage = "{0}长度不能超过{1}")]
		public string City { get; set; }

		/// <summary>
		/// 区、县
		/// </summary>
		[Column("District")]
		[StringLength(50, ErrorMessage = "{0}长度不能超过{1}")]
		public string District { get; set; }

		/// <summary>
		/// 乡镇、街道
		/// </summary>
		[Column("Town")]
		[StringLength(50, ErrorMessage = "{0}长度不能超过{1}")]
		public string Town { get; set; }

		/// <summary>
		/// 详细地址
		/// </summary>
		[Column("DetailAddress")]
		[StringLength(100, ErrorMessage = "{0}长度不能超过{1}")]
		public string DetailAddress { get; set; }

		/// <summary>
		/// 邮编
		/// </summary>
		[StringLength(10, ErrorMessage = "{0}长度不能超过{1}")]
		[Column("ZipCode")]
		public string ZipCode { get; set; }

		/// <summary>
		/// 头像
		/// </summary>
		[Column("AvatarUrl")]
		[StringLength(200, ErrorMessage = "{0}长度不能超过{1}")]
		public string AvatarUrl { get; set; }

		/// <summary>
		/// 出生日期
		/// </summary>
		[Column("BirthDate")]
		public DateTime? BirthDate { get; set; }

		/// <summary>
		/// QQ号
		/// </summary>
		[StringLength(15, ErrorMessage = "{0}长度不能超过{1}")]
		[Column("QQ")]
		public string QQ { get; set; }

		/// <summary>
		/// 微信号
		/// </summary>
		[StringLength(50, ErrorMessage = "{0}长度不能超过{1}")]
		[Column("WX")]
		public string WX { get; set; }

		/// <summary>
		/// 工作单位
		/// </summary>
		[Column("WorkUnit")]
		[StringLength(100, ErrorMessage = "{0}长度不能超过{1}")]
		public string WorkUnit { get; set; }

		/// <summary>
		/// 状态
		/// </summary>
		[Column("StateNow")]
		[Description("状态")]
		public int StateNow { get; set; }

		/// <summary>
		/// 创建时间
		/// </summary>
		[Column("AddDate")]
		public DateTime AddDate { get; set; }

		/// <summary>
		/// 创建人ID
		/// </summary>
		[Column("AddManID")]
		[JsonIgnore]
		public int AddManID { get; set; }

		/// <summary>
		/// 创建人
		/// </summary>
		[Column("AddManName")]
		[StringLength(20, ErrorMessage = "{0}长度不能超过{1}")]
		public string AddManName { get; set; }

		/// <summary>
		/// 最后登录IP
		/// </summary>
		[Column("LastLoginIP")]
		[StringLength(40, ErrorMessage = "{0}长度不能超过{1}")]
		public string LastLoginIP { get; set; }

		/// <summary>
		/// 最后登录时间
		/// </summary>
		[Column("LastLoginDate")]
		public DateTime? LastLoginDate { get; set; }

		/// <summary>
		/// 单位ID
		/// </summary>
		[Column("OrgID")]
		public int OrgID { get; set; }
	}
}
